<template>
  <div class="component-tm">
    <div class="table-page-search-wrapper">
      <a-form-model :model="queryParam" layout="inline">
        <a-row :gutter="48">
          <a-col :md="6" :sm="24">
            <a-form-item label="合同编号">
              <a-input v-model="queryParam['filter[contract_no]']" placeholder="输入合同编号" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-model-item label="业务编号">
              <a-input v-model="queryParam['filter[business_no]']" placeholder="输入业务编号" />
            </a-form-model-item>
          </a-col>
          <template v-if="advanced">
            <a-col :md="6" :sm="24">
              <a-form-model-item label="商标名称">
                <a-input v-model="queryParam['filter[sb_name]']" placeholder="输入商标名称" />
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="注册编号">
                <a-input v-model="queryParam['filter[sb_reg_no]']" placeholder="输入注册编号" />
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="商标类别">
                <a-select @change="tmtpyeChange" v-model="queryParam['filter[sb_category]']" placeholder="选择商标类别">
                  <a-select-option v-for="(option, index) in options['sb_category_opts']" :key="index" :value="index">
                    {{ option }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="业务分类">
                <a-select placeholder="选择业务分类" v-model="queryParam['filter[business_id]']">
                  <a-select-option v-for="option in options['businesses']" :key="option.business_id" :value="option.business_id">
                    {{ option.name }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="进展状态">
<!--                <a-input type="text" v-model="queryParam['filter[state_name]']" />-->
                <a-select v-model="queryParam['filter[state_name]']" placeholder="选择进展状态">
                  <a-select-option value="提交">提交</a-select-option>
                  <a-select-option value="回执">回执</a-select-option>
                  <a-select-option value="补正">补正</a-select-option>
                  <a-select-option value="不予受理">不予受理</a-select-option>
                  <a-select-option value="受理">受理</a-select-option>
                  <a-select-option value="审核">审核</a-select-option>
                  <a-select-option value="公告">公告</a-select-option>
                  <a-select-option value="商标异议">商标异议</a-select-option>
                  <a-select-option value="驳回">驳回</a-select-option>
                  <a-select-option value="下证">下证</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="开启时间">
                <a-range-picker v-model="queryParam['open_time_start']" @change="onSubmitTime" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="更新时间">
                <a-range-picker v-model="queryParam['updated_at_start']" @change="onSubmitTime1" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="业务来源">
                <a-select v-model="queryParam['filter[business_type]']" @change="sourceChange" placeholder="选择业务来源">
                  <a-select-option v-for="(option,index) in options['business_type_opts']" :key="index" :value="index">{{ option }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="客户名称">
                <a-input v-model="queryParam['filter[customer_name]']" placeholder="输入客户名称" />
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="联系电话">
                <a-input v-model="queryParam['filter[phone]']" placeholder="输入联系电话" />
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="未上传材料">
                <a-select v-model="queryParam['filter[is_upload]']" placeholder="选择是否上传了材料">
                  <a-select-option :value="1">是</a-select-option>
                  <a-select-option :value="100">否</a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
          </template>
          <a-col :md="!advanced && 8 || 24" :sm="24">
            <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
              <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
              <a-button style="margin-left: 8px" @click="resetForm">重置</a-button>
              <a @click="toggleAdvanced" style="margin-left: 8px">
                {{ advanced ? '收起' : '展开' }}
                <a-icon :type="advanced ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form-model>
    </div>
    <div class="table-operations">
      <a-card>
        <div class="title">
          <a-tabs v-model="tab" @change="onTabs">
            <a-tab-pane key="today" :tab="`今日更新(${today})`"></a-tab-pane>
            <a-tab-pane key="total" :tab="`全部(${total})`"></a-tab-pane>
          </a-tabs>
        </div>
        <template slot="extra">
          <a-button :disabled="selectedRowKeys.length == 0" style="margin-right:5px" size="small" type="primary" @click="onBatchDownload">批量下载</a-button>
          <a-button style="margin-right:5px" size="small" type="danger" @click="onBatchUpload">批量上传</a-button>
          <a-button size="small" type="primary">筛选倒计时业务</a-button>
        </template>
        <div class="table-operator">
          <s-table
            bordered
            ref="table"
            size="middle"
            :row-key="(record) => record.cb_id"
            :row-class-name="(record) => { if (record.is_read == 0) return 'table-color-dust' }"
            :columns="tmColumns"
            :data="trademarkData"
            :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
          >
            <div
              slot="filterDropdown"
              slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }"
              style="padding: 8px"
            >
              <a-input
                v-ant-ref="c => (searchInput = c)"
                :placeholder="`搜索${column.title}`"
                :value="selectedKeys[0]"
                style="width: 188px; margin-bottom: 8px; display: block;"
                @change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
                @pressEnter="() => handleSearch(selectedKeys, confirm, column.dataIndex)"
              />
              <a-button
                type="primary"
                icon="search"
                size="small"
                style="width: 90px; margin-right: 8px"
                @click="() => handleSearch(selectedKeys, confirm, column.dataIndex)"
              >
                搜索
              </a-button>
              <a-button size="small" style="width: 90px" @click="() => handleReset(clearFilters)">
                重置
              </a-button>
            </div>
            <div
              slot="filterSelect"
              slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }"
              style="padding: 8px"
            >
              <a-select
                show-search
                style="width: 188px; margin-bottom: 8px; display: block;"
                :placeholder="`选择${column.title}`"
                :value="selectedKeys[0]"
                :filter-option="filterOption"
                @change="(value) => setSelectedKeys(value ? [value] : [])"
                @pressEnter="() => handleSelect(selectedKeys, confirm, column.dataIndex)"
              >
                <a-select-option v-for="item in options['businesses']" :key="item.business_id" :value="item.business_id">{{item.name}}</a-select-option>
              </a-select>
              <a-button
                type="primary"
                icon="search"
                size="small"
                style="width: 90px; margin-right: 8px"
                @click="() => handleSelect(selectedKeys, confirm, column.dataIndex)"
              >
                搜索
              </a-button>
              <a-button size="small" style="width: 90px" @click="() => handleReset(clearFilters, column.dataIndex)">
                重置
              </a-button>
            </div>
            <div
              slot="filterSelect3"
              slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }"
              style="padding: 8px"
            >
              <a-select
                show-search
                style="width: 188px; margin-bottom: 8px; display: block;"
                :placeholder="`选择${column.title}`"
                :value="selectedKeys[0]"
                :filter-option="filterOption"
                @change="(value) => setSelectedKeys(value ? [value] : [])"
                @pressEnter="() => handleSelect(selectedKeys, confirm, column.dataIndex)"
              >
                <a-select-option v-for="(item,index) in status" :key="index" :value="index">{{item}}</a-select-option>
              </a-select>
              <a-button
                type="primary"
                icon="search"
                size="small"
                style="width: 90px; margin-right: 8px"
                @click="() => handleSelect(selectedKeys, confirm, column.dataIndex)"
              >
                搜索
              </a-button>
              <a-button size="small" style="width: 90px" @click="() => handleReset(clearFilters, column.dataIndex)">
                重置
              </a-button>
            </div>
            <div
              slot="filterSelect2"
              slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }"
              style="padding: 8px"
            >
              <a-select
                show-search
                style="width: 188px; margin-bottom: 8px; display: block;"
                :placeholder="`选择${column.title}`"
                :value="selectedKeys[0]"
                :filter-option="filterOption"
                @change="(value) => setSelectedKeys(value ? [value] : [])"
                @pressEnter="() => handleSelect(selectedKeys, confirm, column.dataIndex)"
              >
                <a-select-option v-for="(item,index) in options['sb_category_opts']" :key="index" :value="index">{{item}}</a-select-option>
              </a-select>
              <a-button
                type="primary"
                icon="search"
                size="small"
                style="width: 90px; margin-right: 8px"
                @click="() => handleSelect(selectedKeys, confirm, column.dataIndex)"
              >
                搜索
              </a-button>
              <a-button size="small" style="width: 90px" @click="() => handleReset(clearFilters, column.dataIndex)">
                重置
              </a-button>
            </div>
            <div
              slot="filterSelect4"
              slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }"
              style="padding: 8px"
            >
              <a-input-group
                compact
                style="width: 308px; margin-bottom: 8px; display: block;"
              >
                <a-select style="width: 154px" v-model="queryParam['filter[business_id]']" placeholder="业务" @change="businessChange">
                  <a-select-option v-for="item in options['businesses']" :key="item.business_id" :value="item.business_id">{{item.name}}</a-select-option>
                </a-select>
                <a-select style="width: 154px" v-model="queryParam['filter[state_name]']" placeholder="状态" @change="statusChange">
                  <a-select-option v-for="(item,index) in status" :key="index" :value="item">{{item}}</a-select-option>
                </a-select>
              </a-input-group>
<!--              <a-select-->
<!--                show-search-->
<!--                :placeholder="`选择${column.title}`"-->
<!--                :value="selectedKeys[0]"-->
<!--                :filter-option="filterOption"-->
<!--                @change="(value) => setSelectedKeys(value ? [value] : [])"-->
<!--                @pressEnter="() => handleSelect(selectedKeys, confirm, column.dataIndex)"-->
<!--              >-->
<!--                <a-select-option v-for="(item,index) in options['sb_category_opts']" :key="index" :value="index">{{item}}</a-select-option>-->
<!--              </a-select>-->
              <a-button
                type="primary"
                icon="search"
                size="small"
                style="width: 150px; margin-right: 8px"
                @click="() => handleSelect4(selectedKeys, confirm, column.dataIndex)"
              >
                搜索
              </a-button>
              <a-button size="small" style="width: 150px" @click="() => handleReset4(clearFilters, column.dataIndex)">
                重置
              </a-button>
            </div>
            <template slot="business_no" slot-scope="text, record">
              <a-tag color="red" @click="onTag(record.contract_no)">*</a-tag><a-button type="link" @click="toContractDetail(record.contract_no)" style="padding: 0">{{ record.contract_no }}</a-button>
              <br>
              <a-button type="link" @click="toBusinessDetail(record.cb_id)" style="padding: 0">{{ text }}</a-button>
              <a-button type="primary" size="small" @click="postHide(record.cb_id)">隐藏</a-button>
            </template>
            <template slot="sb_category" slot-scope="text">
              <template v-for="(item, index) in options['sb_category_opts']">
                <template v-if="text !== '' && text == index">{{item}}</template>
              </template>
            </template>
            <template slot="subject" slot-scope="text,record">
<!--              <div style="display: flex">-->
<!--                <a-button size="small" type="link" icon="edit" @click="update(record.cb_id)"></a-button>-->
<!--                <a-button size="small" type="link" @click="onSubject(text)">{{text}}</a-button>-->
<!--              </div>-->
              <a :title="text" @click="update(record.cb_id)">{{text}}</a>
            </template>
            <template slot="phone" slot-scope="text, record">
              <a-button :title="text" size="small" type="primary" icon="phone" @click="makePhone(record.customer_id)"></a-button>
            </template>
            <template slot="price" slot-scope="text, record">
              <div class="price">
                <a-tag color="red">价格￥{{ text }}</a-tag>
                <br>
                <a-tag color="red">官费￥{{ record.official_fee }}</a-tag>
              </div>
            </template>
            <template slot="status2" slot-scope="text, record">
              <div v-if="record.state_file_url !== ''">
                <div>
                  <a :href="record.state_file_url" target="_blank">
                    <a-icon :style="{ fontSize: '18px', color: '#1890ff' }" type="file-pdf" />
                  </a>
                  <a @click="downFile(record.state_file_url, record.state_file_name)">
                    <a-icon :style="{ fontSize: '18px', color: '#1890ff' }" type="download" />
                  </a>
                  {{ record.state_name }}
                </div>
                <div>{{record.state_time}}</div>
<!--                <div>{{ record.state_file_name }}</div>-->
              </div>
              <div v-else>
                <a-button v-if="record.status2 == 24" type="danger" icon="edit" size="small" @click="getResult(record.cb_id)">{{record.status2_name }}</a-button>
                <a-button v-if="record.status2 == 10 || record.status2 == 22" type="danger" icon="edit" size="small" @click="getSubmitFill(record.cb_id)">{{ record.status2_name }}</a-button>
                <a-button
                  ghost
                  v-if="record.status2 == 20 || record.status2 == 26"
                  type="danger"
                  size="small"
                  @click="getSubmitFill(record.cb_id)"
                >
                  {{ record.status2_name }}
                </a-button>
                <a-button
                  ghost
                  v-if="record.status2 == 30"
                  type="primary"
                  size="small"
                  @click="getSubmitFill(record.cb_id)"
                >
                  {{ record.status2_name }}
                </a-button>
                <a-button v-if="record.status2 == 40" type="primary" size="small" @click="getSubmitFill(record.cb_id)">{{record.status2_name }}</a-button>
                <a-button v-if="record.status2 == 50" type="dashed" size="small" @click="getSubmitFill(record.cb_id)">{{record.status2_name }}</a-button>
              </div>
            </template>
            <template slot="additional_content" slot-scope="text,record">
              <a-rate :count="1" :disabled="record.exts.length === 0">
                <a-icon slot="character" type="eye" />
              </a-rate>
              <a-button :disabled="record.exts.length === 0" type="link" @click="onExtView(record.exts)">查看</a-button>
            </template>
            <template slot="action" slot-scope="text, record">
              <a-button block type="primary" size="small" @click="toBusinessDetail(record.cb_id)">查看</a-button>
              <a-button block :disabled="record.qid != ''" type="danger" size="small" @click="onQuestion(record.cb_id)">问题</a-button>
            </template>
          </s-table>
        </div>
      </a-card>
    </div>
<!--    <fill v-if="visible9" :fill-key="fillKey" ></fill>-->
    <batch-fill :select-keys="selectedRowKeys" v-if="batchVisible"></batch-fill>
    <fill-modal v-if="visible" :fill-key="fillKey" :from-source="'1'" @submit="handleSubmit" @cancel="handleCancel"></fill-modal>
    <confirm-modal v-if="visible2" :fill-key="fillKey" @submit="handleSubmit1" @cancel="handleCancel1"></confirm-modal>
    <phone-modal v-if="modalVisible" :customer-id="customerId" @cancel="modalExit"></phone-modal>
    <by-contract v-if="visible6" :contract-no="contractNo" :category="type" @cancel="byExit1"></by-contract>
    <by-subject v-if="visible7" :subject="subject" :category="type" @cancel="byExit2"></by-subject>
    <a-modal
      title="提交业务异常申请"
      v-model="visible8"
      @ok="submitQuestion"
    >
      <a-form-model
        ref="questionForm"
        :model="questionForm"
      >
        <a-form-model-item label="问题描述">
          <a-textarea v-model="questionForm.describe" :rows="4"></a-textarea>
        </a-form-model-item>
        <a-form-model-item label="异常附件">
          <a-upload
            name="file"
            :multiple="true"
            :action="updURL"
            :headers="headers"
            @change="onChange"
          >
            <a-button size="small" type="danger">上传附件</a-button>
          </a-upload>
        </a-form-model-item>
      </a-form-model>
    </a-modal>
    <update-subject v-if="visibleUpdate" :sid="sid" @cancel="onCancelUpdate"></update-subject>
    <ext-view v-if="extVisible" @cancel="onCancel"></ext-view>
  </div>
</template>

<script>
  import { STable, PhoneModal } from '@/components'
  import FillModal from '@/views/business/components/FillModal'
  import Fill from '@/views/business/components/Fill'
  import { batchDownload, getList, postFill, postQuestion, getStatus, hideBusiness } from '@/api/business'
  import businessColumns from '@/columns/business'
  import apis from '@/api'
  import ConfirmModal from '@/views/business/components/ConfirmModal'
  import ByContract from '@/views/business/components/ByContract'
  import BySubject from '@/views/business/components/BySubject'
  import storage from 'store'
  import { ACCESS_TOKEN } from '@/store/mutation-types'
  import BatchFill from '@/views/business/components/BatchFill'
  import UpdateSubject from '@/views/business/components/UpdateSubject'
  import ExtView from '@/views/contract/components/ExtView'

  export default {
    props: {
      today: {
        type: Number,
        default: 0
      },
      total: {
        type: Number,
        default: 0
      },
      categoryId: {
        type: String,
        default: '10'
      }
    },
    components: {
      BatchFill,
      ConfirmModal,
      FillModal,
      STable,
      PhoneModal,
      ByContract,
      BySubject,
      Fill,
      UpdateSubject,
      ExtView
    },
    name: 'Trademark',
    data () {
      return {
        tab: 'today',
        labelCol: { span: 6 },
        wrapperCol: { span: 18 },
        searchInput: null,
        tmColumns: businessColumns.tmColumns,
        trademarkData: parameters => {
          return getList(Object.assign(parameters, this.queryParam)).then(res => {
            this.options['businesses'] = res.result.businesses
            this.options['sb_category_opts'] = res.result.sb_category_opts
            this.options['business_type_opts'] = res.result.business_type_opts
            return res.result
          })
        },
        advanced: true,
        queryParam: {},
        options: {},
        status: {},
        selectedRowKeys: [],
        visible: false,
        visible2: false,
        fillKey: '',
        customerId: '',
        contractNo: '',
        subject: '',
        type: '',
        modalVisible: false,
        visible6: false,
        visible7: false,
        visible8: false,
        questionForm: {},
        updURL: apis.Upload,
        headers: {
          'Access-Token': storage.get(ACCESS_TOKEN)
        },
        visible9: true,
        batchVisible: false,
        sid: '',
        visibleUpdate: false,
        bid: '',
        extVisible: false,
        extList: []
      }
    },
    created () {
      this.queryParam['filter[category]'] = this.categoryId
      this.type = this.categoryId
      this.queryParam['filter[is_update]'] = 'today'
      // getStatus(this.categoryId).then(res => {
      //   this.status = res.result.items
      // })
    },
    methods: {
      onExtView (ext) {
        this.extList = ext
        this.extVisible = true
      },
      onCancel (visible) {
        this.extVisible = visible
      },
      onQuestion (id) {
        this.questionForm['id'] = id
        this.visible8 = true
      },
      makePhone (id) {
        this.customerId = id
        this.modalVisible = true
      },
      modalExit (visible) {
        this.modalVisible = visible
      },
      byExit1 (visible) {
        this.visible6 = visible
      },
      byExit2 (visible) {
        this.visible7 = visible
      },
      handleSelect (selectedKeys, confirm, dataIndex) {
        confirm()
        this.searchText = selectedKeys[0]
        this.searchedColumn = dataIndex
        this.queryParam['filter[' + dataIndex + ']'] = selectedKeys[0]
      },
      handleSelect4 (selectedKeys, confirm, dataIndex) {
        confirm()
        this.searchText = selectedKeys[0]
        this.searchedColumn = dataIndex
        this.$refs.table.refresh(true)
      },
      handleReset4 (clearFilters) {
        clearFilters()
        delete this.queryParam['filter[state_name]']
        delete this.queryParam['filter[business_id]']
        this.$refs.table.refresh(true)
      },
      toBusinessDetail (id) {
        this.$router.push({ name: 'BusinessDetail', params: { id } })
      },
      toContractDetail (id) {
        this.queryParam['filter[contract_no]'] = id
        this.$refs.table.refresh(true)
        // this.$router.push({ name: 'ContractDetail', params: { cid: id } })
      },
      toggleAdvanced () {
        this.advanced = !this.advanced
      },
      handleSearch (selectedKeys, confirm, dataIndex) {
        confirm()
        this.searchText = selectedKeys[0]
        this.searchedColumn = dataIndex
      },
      handleReset (clearFilters) {
        clearFilters()
      },
      onTag (no) {
        this.contractNo = no
        this.visible6 = true
      },
      handleSubmit1 (form) {
        const app = this
        form['cb_id'] = app.fillKey
        postFill(form).then(res => {
          if (res.status === 0) {
            app.$refs.table.refresh()
            app.handleCancel1()
          } else {
            app.$warning({
              title: res.msg
            })
          }
        })
      },
      handleSubmit (form) {
        const app = this
        form['cb_id'] = app.fillKey
        postFill(form).then(res => {
          if (res.status === 0) {
            app.$refs.table.refresh()
            app.handleCancel()
          } else {
            app.$warning({
              title: res.msg
            })
          }
        })
      },
      handleCancel1 (visible) {
        this.visible2 = visible
      },
      handleCancel (visible) {
        this.visible = visible
      },
      onSelectChange (selectedRowKeys) {
        this.selectedRowKeys = selectedRowKeys
      },
      downFile (value, filename) {
        window.open(apis.Download + '?value=' + value + '&filename=' + filename)
      },
      getResult (id) {
        this.fillKey = id
        this.visible2 = true
      },
      getSubmitFill (id) {
        this.fillKey = id
        this.visible = true
      },
      tmtpyeChange (e) {
        if (e !== '') {
          this.queryParam['filter[sb_category]'] = e
        } else {
          delete this.queryParam['filter[sb_category]']
        }
      },
      businessChange (e) {
        getStatus(e).then(res => {
          this.status = res.result.items
          this.queryParam['filter[business_id]'] = e
        })
      },
      statusChange (e) {
        this.queryParam['filter[state_name]'] = e
      },
      sourceChange (e) {
        if (e !== '') {
          this.queryParam['filter[business_type]'] = e
        } else {
          delete this.queryParam['filter[business_type]']
        }
      },
      onSubmitTime (date, dateString) {
        for (let i = 0; i < dateString.length; i++) {
          if (i === 0) {
            this.queryParam['filter[open_time_start]'] = dateString[i]
          }
          if (i === 1) {
            this.queryParam['filter[open_time_end]'] = dateString[i]
          }
        }
      },
      onSubmitTime1 (date, dateString) {
        for (let i = 0; i < dateString.length; i++) {
          if (i === 0) {
            this.queryParam['filter[updated_at_start]'] = dateString[i]
          }
          if (i === 1) {
            this.queryParam['filter[jhjuihuhughupdated_at_end]'] = dateString[i]
          }
        }
      },
      resetForm () {
        this.queryParam = {}
        this.queryParam['filter[category]'] = this.categoryId
        this.queryParam['filter[is_update]'] = 'today'
        this.tab = 'today'

        this.$refs.table.refresh(true)
      },
      onSubject (subject) {
        this.subject = subject
        this.visible7 = true
      },
      filterOption (input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        )
      },
      onChange (info) {
        const app = this
        if (info.file.status === 'uploading') {
          return false
        }
        if (info.file.status === 'done') {
          app.questionForm['file'] = info.file.response.result.url
          app.questionForm['filename'] = info.file.response.result.name
        }
      },
      submitQuestion () {
        const app = this
        const data = {}
        app.$refs.questionForm.validate(valid => {
          if (valid) {
            for (const k in app.questionForm) {
              data['question[' + k + ']'] = app.questionForm[k]
            }
            postQuestion(app.questionForm.id, data).then(res => {
              app.visible8 = false
              app.$refs.table.refresh()
            })
          } else {
            return false
          }
        })
      },
      onTabs (key) {
        this.tab = key
        this.queryParam['filter[is_update]'] = key
        this.$refs.table.refresh()
      },
      onBatchUpload () {
        this.batchVisible = true
      },
      onBatchDownload () {
        const params = {}
        params['cb_ids'] = this.selectedRowKeys
        batchDownload(params).then(res => {
          if (res.status === 0) {
            window.open(res.result.fileUrl)
          } else {
            this.$warning({
              title: res.msg
            })
          }
        })
      },
      update (id) {
        this.sid = id
        this.visibleUpdate = true
      },
      onCancelUpdate (visible) {
        this.visibleUpdate = visible
        this.$refs.table.refresh(true)
      },
      postHide (id) {
        hideBusiness(id).then(res => {
          if (res.status === 0) {
            this.$refs.table.refresh()
          } else {
            this.$warning({
              title: res.msg
            })
          }
        })
      }
    }
  }
</script>

<style scoped>
  .price {
    line-height: 30px;
  }

  .note >>> img {
    display: block;
    width: 100%;
  }

  .base-info-scroll {
    height: 700px;
    overflow-x: hidden;
    overflow-y: scroll;
    padding: 0 15px;
  }
  /deep/ .ant-table-tbody > tr.table-color-dust {
    background-color: #ffcccc;
  }
</style>
